/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.worlds.ui.edge;


public class EMenuTitle extends EButton{
    private EMenu menu;
    public EMenuTitle(final EMenu menu, String title, int x)
    {
        super(title);
        setX(x);
        setY(0);
        this.setFont(EDGESettings.menuFont);
        this.menu = menu;
        setActionListener(new EActionListener()
        {
            @Override
            public void actionPerformed() {
                if(menu.visible)
                    menu.setVisible(false);
                else
                    menu.setVisible(true);
            }
        });
    }
    public void hideMenu()
    {
        menu.setVisible(false);
    }
    public void showMenu()
    {
        menu.setVisible(true);
    }
    @Override
    public void mouseOver()
    {
        super.mouseOver();
        boolean found = false;
        for(EComponent c : EDGESettings.menuBar.getChildren(1))
        {
            if(c instanceof EMenuTitle && ((EMenuTitle)c).menu.visible)
            {
                ((EMenuTitle)c).menu.setVisible(false);
                found = true;
            }
        }
        if(found)
            menu.setVisible(true);
    }
}
